package servlet;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/servlet")
public class Servlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ArrayList<User> userList = new ArrayList();
        userList.add(new User("tom", 12, 0));
        userList.add(new User("jerry", 13, 1));

        System.out.println(userList);

        request.setAttribute("userList", userList);
        request.getRequestDispatcher("/jstl-foreach.jsp").forward(request, response);
    }
}